package com.lanhe.member.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lanhe.member.domain.LhMemberConsumedRec;
import com.lanhe.member.domain.dto.LhMemberConsumedStatDTO;
import com.lanhe.member.mapper.LhMemberConsumedRecMapper;
import com.lanhe.member.service.ILhMemberConsumedRecService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * 用户消费记录(LhMemberConsumedRec)表服务实现类
 *
 * @author zhanggl
 * @since 2024-01-16 10:46:23
 */
@Service
public class LhMemberConsumedRecServiceImpl extends ServiceImpl<LhMemberConsumedRecMapper, LhMemberConsumedRec> implements ILhMemberConsumedRecService {
    @Autowired
    private LhMemberConsumedRecMapper lhMemberConsumedRecMapper;

    //今日的消费次数和总额
    @Override
    public LhMemberConsumedStatDTO selectConsumptionToday() {
        return lhMemberConsumedRecMapper.selectConsumptionToday();
    }
    // 本月的消费次数和总额
    @Override
    public LhMemberConsumedStatDTO selectConsumptionMonth() {
        return lhMemberConsumedRecMapper.selectConsumptionMonth();
    }
    // 累计的消费次数和总额
    @Override
    public LhMemberConsumedStatDTO selectConsumptionSum() {
        return lhMemberConsumedRecMapper.selectConsumptionSum();
    }

    /**
     * 插入数据
     *
     * @param consumedRec 实体
     * @return com.lanhe.member.domain.dto.LhMemberConsumedStatDTO
     * @author zhanggl
     * @date 2024/1/22
     */
    @Override
    public int insertMemberConsumedRec(LhMemberConsumedRec consumedRec) {
        consumedRec.setCreateTime(new Date());
        return lhMemberConsumedRecMapper.insert(consumedRec);
    }
}

